package com.finance.cooperate.dao.repository.secondary;

import com.finance.cooperate.dao.entity.secondary.DiversionInfo;
import com.finance.cooperate.dao.support.jpa.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * @InterfaceName DiversionInfoRepository
 * @Description 模型分流器仓库
 * @Author shen
 * @Date 2023/8/6 21:46
 * @Modify ...
 */
@Repository
public interface DiversionInfoRepository extends BaseRepository<DiversionInfo, Long> {

    /**
     * @Author shen
     * @Description 根据名称查询
     * @Date 6:23 下午 2021/2/23
     * @Param [name, project]
     * @return cm.finance.crm.dao.entity.secondary.DiversionInfo
     **/
    DiversionInfo findByNameAndProject(String name, String project);

    /**
     * @Author shen
     * @Description 根据模型ID查询
     * @Date 10:44 上午 2021/2/24
     * @Param [modelId]
     * @return cm.finance.crm.dao.entity.secondary.DiversionInfo
     **/
    @Query(value = "SELECT * FROM rc_diversion_info d LEFT JOIN rc_model_info m ON d.id = m.diversion_id WHERE m.id = ?1", nativeQuery = true)
    DiversionInfo getByModelId(Long modelId);

}
